<?php

namespace app\common\controller;


use app\api\controller\Error;
use app\BaseController;
use app\common\service\SignService;
use think\exception\ValidateException;
use app\api\model\Order;

class ApiController extends BaseController
{
    // 跳过验签的方法
    protected $noNeedSign = [
        'doPoints',
    ];

    public $app_type;


    protected function initialize()
    {
        $action = request()->action();
        if (!in_array($action, $this->noNeedSign)) {
            $this->verifySign();
        }
    }

    protected function verifySign()
    {
        $params = request()->param();
        
        $signRider = new SignService();
        $res = $signRider->verifyRiderSign($params);
        $status = !empty($res['status']) ? $res['status'] : 0;
        if (empty($status)){
            $msg = !empty($res['msg']) ? $res['msg'] : '签名验证失败';
            output_error($msg);
        }
    }

}